Skip to content

ci(doop): train S4c sandbox, isolation probes, env allowlist, sweep, smoke (CHE-5548) [squash] - #56

Merged
congvc-dev merged 18 commits into
cheese/mainfrom
agent/tofu/che-5548-2644b627ca4a
Nov 23, 2026
Merged

congvc-dev merged 18 commits into
cheese/mainfrom
agent/tofu/che-5548-2644b627ca4a

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

What this is

Closes CHE-5548

Train slice S4c of CHE-5474 (rules C-8.5b to C-8.5d), issue CHE-5548. Stacked on #53 (S4b-1 runner), now merged, so the base is cheese/main.

DOOP_DEPLOY_TRAIN stays absent or off. This approves no deploy. Nothing here is called by a workflow yet: wiring waits for S2 (#46) and S5. Gate-path slice: needs a cross-lab code signer (x99-codex-terra). No review is waived.

What is added

  • scripts/compat-sandbox.mjs: runCompat clones the live DB into a docker network create --internal network (pg_dump | pg_restore, no pull, no build, no published port, no mount), runs the candidate migration (server/db/migrate.ts, S4b-1) on the clone, runs the isolation probes, boots the predecessor and runs the smoke suite from the candidate image. verifyEvidence and ledgerHash are deploy step 1. CLI: run, verify.
  • scripts/compat-env.mjs: the exact 7-key predecessor env (never copied from process.env).
  • scripts/deploy-smoke.mjs + deploy/cd/smoke-routes.json: one read and one write for each of the 44 route groups. scripts/route-groups.mjs derives the groups from server/.
  • deploy/cd/c00.sh sweep: removes every doop.compat.run container, network, volume (in that order), reads back zero, prints df before and after. Needs no compose dir and no deploy ref.
  • Dockerfile: copies the smoke script and routes file into the runtime stage.

Test-first evidence (observed)

Red: tests written first, run against stubs of the new modules and no sweep command. Result: Test Files 4 failed (4), Tests 56 failed | 8 passed | 4 skipped (68). The 8 passes are pure-stub coincidences (negative cases). The 4 skipped are the Docker fixture, whose beforeAll failed against the stub. Green after implementation: Test Files 5 passed (5), Tests 94 passed (94) (the four new files plus tests/c00Deploy.test.ts), real Docker included.

Done-when item Test (red before, green after)
Insufficient: changed column, new unique index, missing snapshot static diff that is insufficient stops before any sandbox exists, a missing static result is insufficient
Migration fails on clone data a migration that fails on the existing data is insufficient, and the predecessor never starts
Predecessor health or a smoke call fails predecessor health or a smoke call failing on the clone is insufficient, smoke output that cannot be read is insufficient
Low disk low disk (free < 3x the live database) is insufficient and nothing is cloned
Route group missing from smoke-routes.json fails CI reports a server group that smoke-routes.json does not list, gives every listed group one read and one write, passes every listed read and write (real server, 88 calls)
Scratch DB dropped after success and failure sweeps first and again at the end, after success, sweeps at the end after a failure too…, …when an unexpected error escapes, and rethrows it
Evidence for another predecessor digest or ledger hash refused at step 1 refuses evidence for another predecessor digest, …another ledger hash, …another candidate sha, refuses failed, partial, missing and unreadable evidence
Internal network cannot reach external address, host gateway, live Postgres on another network, DNS; also from a background worker after boot (real Docker, node:22-slim) tests/compatIsolationDocker.test.ts: a container on the internal network cannot reach…, a background worker that starts after boot cannot reach out either, plus a positive control (the probe can tell…)
Predecessor env holds only allowlisted keys starts the predecessor with only the allowlisted env, no mounts, cap-drop ALL, read-only, tmpfs /tmp, a predecessor whose inspect shows a foreign env key, a mount or a published port blocks startup
Any probe that succeeds blocks startup a probe that reaches an external address blocks startup, reaching %s blocks startup (x3), a probe that cannot run…, …leaves a target unanswered…, a network that is not Internal, or holds a foreign container…
Production env key added to the allowlist fails CI every other key in server/env.ts is absent from the allowlist…
After a killed job the next C00 job sweeps and reads back zero; a failed sweep blocks the job tests/c00Sweep.test.ts (stub docker) and after a killed compat job the next sweep removes every labelled resource and reads back zero (real Docker); a failed first sweep fails the job before any other step, …removal itself fails

Other checks: bun run typecheck, bun run lint, bun run format:check, bun run build pass. doc-lint passes with one stale-docs warning. /verify pregate test lane reported TIMEOUT: it selects tests against origin/main, which here is the whole unmerged stack. I ran the slice's files directly instead.

Not observed here (say so before relying on it)

  1. No end-to-end runCompat against a real Postgres image and a built candidate image. The orchestrator is proven against a scripted Docker; isolation is proven with real Docker on a fixture. The first real C00 run will be the first time pg_dump | pg_restore, the --read-only predecessor boot and the smoke run meet real images. If the app needs a writable path beyond /tmp, the smoke step fails closed (insufficient evidence), not open.
  2. The CLI run wiring (gateway and live Postgres address lookup, the real runner) has no automated test.
  3. Workflow wiring: not in this slice.

Cleanup

Docker fixture resources are labelled doop.compat.run and removed by c00.sh sweep in its own afterAll; read back zero. node:22-slim stays pulled on X99.

CHE-7697 fix round: smoke write chains (head 50608e1f)

Finding (x99-codex-terra, P1 silent-guard, C-8.5c: one read and one write per route group): /api/agents and /api/image-descriptions only read; /api/custom-providers had a GET 404-or-200 contract that an absent route passes.

  • /api/agents: POST create, GET read-back, PATCH blurb, GET read-back, all on the throwaway user in the clone. noWrite removed.
  • /api/image-descriptions: GET (default account), PUT {mode:'off'}, GET read-back. noWrite removed.
  • /api/custom-providers: POST {} contract with new expectByStatus: 400 must carry Give the provider a name (feature on), 404 must carry custom providers are off on this server (feature off). Any other status or body fails, so an absent route, a 200 or a 5xx fails.
  • scripts/deploy-smoke.mjs: expectByStatus support (the allowed statuses are its keys; the body check follows the status that came back).

Test command: bunx vitest run tests/compatSmoke.test.ts tests/compatSandbox.test.ts tests/c00Guard.test.ts tests/c00Sweep.test.ts

Red (new tests, before the fix, booted server on X99): tests/compatSmoke.test.ts Tests 6 failed | 21 passed (27): the two route-shape tests, the expectByStatus scripted test, and the real-server tests for agents, image-descriptions and custom-providers.
Green (this head): compatSmoke Tests 27 passed (27); the four files together Test Files 4 passed (4), Tests 147 passed (147). bun run typecheck and oxlint on the changed files pass.

Failing-write proof (real server): a refused POST /api/agents (body {name:'x'}), a PATCH whose read-back differs, a refused PUT mode (nonsense) and a PUT mode server read back as off each make runSmoke fail and name the group. The custom-providers contract passes on a server with the feature on (400) and on one booted with DOOP_CUSTOM_PROVIDERS=false (404), and a wrong expected body fails.

DOOP_DEPLOY_TRAIN stays absent or off. This approves no deploy. Nothing built or run on C00.

Changelog

No user-facing change. CI-only: the deploy train's compat smoke suite now writes and reads back /api/agents and /api/image-descriptions and checks a real on/off contract for /api/custom-providers. Not released; the train switch stays off.

congvc-bot[bot] added 4 commits November 18, 2026 11:29
…d (CHE-5548)

- proveQuiescence: kill, wait, record (pid, backend_start), terminate, prove three
  facts inside one 30 s budget; every step bounded; a timeout leaves a fact unproven.
- Failed migration: clone ledger must equal the pre-migration ledger.
- needs_operator writes a guard file that no sweep removes, keeps the sandbox, skips
  the final sweep. runCompat, c00.sh apply, rollback, sweep and guard refuse until
  the facts hold; lift calls c00.sh guard.
- Tests: stuck docker kill/wait/inspect/psql, later job after a failed proof,
  c00.sh refusal. Run against the previous implementation: 67 of 107 failed.
  Written after the code, so retrospective test-first.
…ion, clear it only after proof (CHE-5548)

Red (6 failures) before the change, green (174 passed across compat and c00 suites) after.
@congvc-dev
congvc-dev force-pushed the agent/tofu/che-5548-2644b627ca4a branch from e9b8b03 to 212ddb7 Compare November 18, 2026 04:29
congvc-bot[bot] added 10 commits November 18, 2026 21:46
…imports (CHE-7020)

Chrome aborts in-flight requests with net::ERR_NETWORK_CHANGED when host
network interfaces change. The module script in drawing.html then never sets
window.drawingHarness and no wait recovers. Print pageerror/requestfailed/
readyState on a stall and load the page again (3 tries, 8s ready wait).
…E-7021)

The first seedPanel wait timed out at the 5 s puppeteer default on CI shard 2
(run 44129413615, job 134202011472). Widen the file default and the one
explicit 5 s poll to 12 s, under the 15 s per-test limit.
…-6841)

cheese/main carries its own flake fix (doop-design#433) and the ci-policy R1 push-trigger
rule, so the #64 commits are dropped here and the test files take main's
version. Smoke routes gain /api/agent-runners and /api/fonts and follow the
new /api/model-account view.
@congvc-bot-x99 congvc-bot-x99 Bot changed the title ci(doop): train S4c compat sandbox, isolation probes, env allowlist, sweep, smoke (CHE-5548) ci(doop): train S4c compat sandbox, isolation probes, env allowlist, sweep, smoke (CHE-5548) [squash] Nov 20, 2026
…-5549) [squash] (#99)

* ci(doop): train S5 readback delay, confirm, rollback readback, evidence (CHE-5549)

Rules C-9 and C-12 of CHE-5474. Ships with DOOP_DEPLOY_TRAIN absent or off.

* ci(doop): prove quiescence and decide confirm and rollback under the lock (CHE-5549)

Review round 1 on the S5 slice:
- deploy-gate recheck runs the real quiescence proof (c00.sh quiescence) instead of a hardcoded ok.
- c00.sh confirm and rollback prove migration quiescence under the lock, switch on or off.
- The confirm and rollback checks run inside c00.sh after take_lock, so a newer deployment or a changed marker that
  lands while waiting for the lock is seen (superseded, none, refused); the workflow no longer decides before the lock.
- The rollback job is one c00.sh step; the marker token and suspension follow the step's own go output.

* fix(cd): give readback-confirm the compose dir and Postgres container (CHE-5549)

Quiescence in confirm reads the live database, so the job needs the same
C00_COMPOSE_DIR and C00_PG_CONTAINER as deploy and rollback. Test drives
c00.sh with only each job's own env block.

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>
@congvc-bot-x99 congvc-bot-x99 Bot changed the title ci(doop): train S4c compat sandbox, isolation probes, env allowlist, sweep, smoke (CHE-5548) [squash] ci(doop): train S4c sandbox, isolation probes, env allowlist, sweep, smoke (CHE-5548) [squash] Nov 20, 2026
…#103)

* ci(doop): train S5 readback delay, confirm, rollback readback, evidence (CHE-5549)

Rules C-9 and C-12 of CHE-5474. Ships with DOOP_DEPLOY_TRAIN absent or off.

* ci(doop): prove quiescence and decide confirm and rollback under the lock (CHE-5549)

Review round 1 on the S5 slice:
- deploy-gate recheck runs the real quiescence proof (c00.sh quiescence) instead of a hardcoded ok.
- c00.sh confirm and rollback prove migration quiescence under the lock, switch on or off.
- The confirm and rollback checks run inside c00.sh after take_lock, so a newer deployment or a changed marker that
  lands while waiting for the lock is seen (superseded, none, refused); the workflow no longer decides before the lock.
- The rollback job is one c00.sh step; the marker token and suspension follow the step's own go output.

* fix(cd): give readback-confirm the compose dir and Postgres container (CHE-5549)

Quiescence in confirm reads the live database, so the job needs the same
C00_COMPOSE_DIR and C00_PG_CONTAINER as deploy and rollback. Test drives
c00.sh with only each job's own env block.

* ci(doop): train S7 watchers and /healthz revision (CHE-5550)

* fix(ci): keep the last confirmed deploy durably for the D2 watchers (CHE-5550)

The watchers searched only the 30 newest D2 runs for a confirmed deployment.
After 30 skipped slots the SHA came back null: the live watch then passed an
unreachable /healthz and the freshness watch treated the deployed candidate as
overdue.

- D2's evidence job records each confirmed deploy as a GitHub deployment
  (environment c00-doop, deployments: write), read back before the step passes.
- The last successful D2 SHA is tri-state: known, none (a proven first
  deployment) or unknown. Unknown history alarms and fails visibly.
- Artifact scan is only the fallback: paginated, up to 100 runs, and a green
  run whose evidence is gone counts as unknown.
- /healthz must be healthy with a 40-hex revision even when nothing deployed.

* fix(ci): reconcile the deploy record with newer D2 evidence and send typed booleans (CHE-5550)

A prior deployment record no longer hides a newer confirmed deploy whose own
record write failed: that history is unknown and fails both watchers visibly.
The record carries its D2 run id; auto_merge and production_environment go
out as JSON booleans (gh api -F) and the request and failure path are tested.

* fix(ci): treat a newer D2 run with no evidence as unknown, not skipped (CHE-5550)

* fix(ci): order the last confirmed D2 deploy by confirmation time, not run ID (CHE-8873, CHE-5550)

Round 4 P1: an older run can confirm after a newer run recorded another SHA. Check every run
active at or after the record's confirmation, treat unfinished runs as pending/stuck, record the
confirmation time in the deployment description.

* fix(ci): a pending D2 run no longer hides the 90 min alarm or a failed /healthz (CHE-8873, CHE-5550)

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>
@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review November 20, 2026 23:47
congvc-bot-x99 Bot and others added 2 commits November 23, 2026 10:57
* ci(doop): train S3b — audited lift workflow (CHE-5551)

Add cd-lift.yml, the only way from armed/suspended back to clear (plan CHE-5474
C-10.6, C-10.7). Dispatch only, one input (decision_id), allowlisted dispatcher,
C00 runner under the host deploy lock.

scripts/deploy-lift.mjs refuses unless the Multica decision is an approved
doop.deploy_lift by the configured approver, not withdrawn/revoked/expired, its
marker_value equals the standing marker and repo matches, quiescence and
/healthz are proven, and the decision and marker still hold when re-read right
before the write. It then writes clear:<nonce>:<run id>, reads it back and
records lift-evidence.json. A refusal leaves the marker unchanged.

c00.sh gains a `lift` command (guard, lock, quiescence, digest, revision label,
container health). deploy-marker.mjs gains lift() and exports readMarker().
The train switch DOOP_DEPLOY_TRAIN is not touched.

* fix(ci): lift refuses a decision answer that omits withdrawn_at, revoked_at or expires_at (CHE-5551)

---------

Co-authored-by: congvc-bot[bot] <3634010+congvc-bot[bot]@users.noreply.github.com>
@congvc-dev
congvc-dev merged commit 3a5078f into cheese/main Nov 23, 2026
11 checks passed
@congvc-dev
congvc-dev deleted the agent/tofu/che-5548-2644b627ca4a branch November 23, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant